package com.itheima.controller;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//设置rest风格的控制器，相当于 @Controller + @ResponseBody
@RestController
//设置公共访问路径，配合下方访问路径使用
@RequestMapping("/user/")
public class UserController {

    //接收GET请求简化配置方式
    @GetMapping("{id}")
    public String get(@PathVariable Integer id) {
        System.out.println("restful is running ....get: " + id);
        return "restful is running ....get: " + id;
    }

    //接收POST请求简化配置方式
    @PostMapping("{id}")
    public String post(@PathVariable Integer id) {
        System.out.println("restful is running ....post:" + id);
        return "restful is running ....post: " + id;
    }

    //接收PUT请求简化配置方式
    @PutMapping("{id}")
    public String put(@PathVariable Integer id) {
        System.out.println("restful is running ....put:" + id);
        return "restful is running ....put: " + id;
    }

    //接收DELETE请求简化配置方式
    @DeleteMapping("{id}")
    public String delete(@PathVariable Integer id) {
        System.out.println("restful is running ....delete:" + id);
        return "restful is running ....delete: " + id;
    }


}
